package com.evl.refundOrder.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.evl.common.constant.OrderConst;
import com.evl.common.persistence.dao.RefundOrderMapper;
import com.evl.common.persistence.model.RefundOrder;
import com.evl.constant.TrainSeatType;
import com.evl.refundOrder.service.IRefundOrderService;
import com.evl.utils.ObjectUtil;
import com.evl.utils.filter.ListFilter;

/**
 * <p>
 * 退票管理 服务实现类
 * </p>
 *
 * @author dangsheng
 * @since 2017-06-22
 */
@Service
public class RefundOrderServiceImpl implements IRefundOrderService {

	@Resource
	RefundOrderMapper refundOrderMapper;
	
	@Override
	public List<Map> searchRefundOrderList(RefundOrder refundOrder) {
		List<Map> rest = refundOrderMapper.selectRefundOrderList(refundOrder);
		if(rest == null){
			return null;
		}
		for (int i = 0; i < rest.size(); i++) {
			Map m = rest.get(i);
			Double radio = (Double) (m.get("refundRadio")==null?null:m.get("refundRadio"));
			if(radio != null){
				m.put("refundRadio", radio*100);
			}
			String status = m.get("status")==null?"":m.get("status").toString();
			if(status.equals(OrderConst.REFUND_ORDER_STATUS_WAIT)){
				m.put("status", "未退款");
			}else if(status.equals(OrderConst.REFUND_ORDER_STATUS_END)){
				m.put("status", "已退款");
			}else if(status.equals(OrderConst.REFUND_ORDER_STATUS_ERROR)){
				m.put("status", "退款异常");
			}
			
			String seatType = m.get("seatType")==null?"":m.get("seatType").toString();
			if(status.equals(TrainSeatType.top_Soft.getCode()+"")){
				m.put("seatType", TrainSeatType.top_Soft.getName());
			}else if(status.equals(TrainSeatType.top_Tourist.getCode()+"")){
				m.put("seatType", TrainSeatType.top_Tourist.getName());
			}else if(status.equals(TrainSeatType.bottom_Soft.getCode()+"")){
				m.put("seatType", TrainSeatType.bottom_Soft.getName());
			}else if(status.equals(TrainSeatType.bottom_Tourist.getCode()+"")){
				m.put("seatType", TrainSeatType.bottom_Tourist.getName());
			}
			
			String depTime = m.get("depTime")==null?"":m.get("depTime").toString();
			if(!depTime.equals("")){
				m.put("depTime", depTime.substring(0, 10));
			}
		}
		return rest;
	}
	
	
	
}
